package com.cto.cloud.entity;

import java.util.Collection;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonIgnore;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

/**
 * <p></p>
 * @author Zhang Yongwei
 * @date 2020/12/18 11:15
 */
public class CustomUser implements UserDetails {

	private Integer id;
	private String username;
	@JsonIgnore
	private String password;
	private String rawPass;
	@JsonIgnore
	private List<String> roles;
	private List<? extends GrantedAuthority> authorities;

	@Override
	@JsonIgnore
	public Collection<? extends GrantedAuthority> getAuthorities() {
		return authorities;
	}

	@Override
	public String getPassword() {
		return password;
	}

	@Override
	public String getUsername() {
		return username;
	}

	@Override
	public boolean isAccountNonExpired() {
		return true;
	}

	@Override
	public boolean isAccountNonLocked() {
		return true;
	}

	@Override
	public boolean isCredentialsNonExpired() {
		return true;
	}

	@Override
	public boolean isEnabled() {
		return true;
	}
}
